/**
 * 文件名称:StorageAction.java
 * 文件版权:ChinaParasol Technologies Co., Ltd. Copyright 1998-2020, All rights reserved
 * 文件描述:<描述>
 * 修改作者:LiXiangDong
 * 修改时间:Jan 8, 2013
 */
package com.parasol.hcerp.service.storage.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.parasol.hcerp.common.action.ParasolAction;
import com.parasol.hcerp.service.chipmodel.service.ChipmodelService;
import com.parasol.hcerp.service.measurement.domain.MeasurementBean;
import com.parasol.hcerp.service.measurement.service.MeasurementService;
import com.parasol.hcerp.service.storage.domain.StorageBean;
import com.parasol.hcerp.service.storage.domain.StorageParameBean;
import com.parasol.hcerp.service.storage.domain.StorageShowBean;
import com.parasol.hcerp.service.storage.service.StorageService;

/**
 * 
 * @author  LiXiangDong
 * @version V1.0
 */
public class StorageAction extends ParasolAction
{

    private static final long serialVersionUID = 4434259662859724127L;
    
    //生产流程
    private StorageService storageService =null;
    
    //芯片规格
    private ChipmodelService chipmodelService = null;
    
    //计量单位
    private MeasurementService measurementService = null;
    
    //入库查询参数
    private StorageParameBean storageParameBean = null;
    
    private StorageBean storageBean = null;
    
    private String storageid = null;
    
    public StorageService getStorageService()
    {
        return storageService;
    }

    public void setStorageService(StorageService storageService)
    {
        this.storageService = storageService;
    }

    public StorageBean getStorageBean()
    {
        return storageBean;
    }

    public void setStorageBean(StorageBean storageBean)
    {
        this.storageBean = storageBean;
    }

    public String getStorageid()
    {
        return storageid;
    }

    public void setStorageid(String storageid)
    {
        this.storageid = storageid;
    }

    public String queryForStorageList()
    {
        super.clientCache();
        List<StorageShowBean> storageShowList = storageService.queryForStorageList(storageParameBean);
        HttpServletRequest request = super.getRequest();
        request.setAttribute("storageList", storageShowList);
        
        int result = storageService.queryForStorageListCount(storageParameBean);
        request.setAttribute("result", result);
        return SUCCESS;
    }
    
    public String saveForStorageJump()
    {
        super.clientCache();
        return SUCCESS;
    }
    
    public String saveForStorage()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        
        storageService.saveForStorage(storageBean);
        List<StorageShowBean> storageShowList = storageService.queryForStorageList(storageParameBean);
        request.setAttribute("storageList", storageShowList);
        return SUCCESS;
    }
    
    public String updateForStorageJump()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        storageid = request.getParameter("storageid");
        StorageShowBean storageShowBean = storageService.queryForStorage(storageid);
        request.setAttribute("storageBean", storageShowBean);
        
        //规格编号
        storageBean = storageService.queryForSpecificationsid(storageid);
        request.setAttribute("bean", storageBean);
        
        //计量单位
        List<MeasurementBean> measurementList = measurementService.queryForMeasurementList();
        request.setAttribute("measurementList", measurementList);
        
        //查询计量单位
        MeasurementBean measurementBean = measurementService.queryForMeasurement(storageBean.getMeasurementid());
        request.setAttribute("measurementBean", measurementBean);
        return SUCCESS;
    }
    
    public String updateForStorage()
    {
        super.clientCache();
        int result = storageService.queryForStorageExist(storageBean);
        HttpServletRequest request = super.getRequest();
        if (result > 0)
        {
            request.setAttribute("errorMessage", "数据已经存在，添加失败");
            return ERROR;
        }
        
        storageService.updateForStorage(storageBean);
        List<StorageShowBean> storageShowList = storageService.queryForStorageList(storageParameBean);
        request.setAttribute("storageList", storageShowList);
        return SUCCESS;
    }
    
    public String deleteForStorage()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        
        String storageids = request.getParameter("storageid");
        
        String[] storageid = storageids.split("~");
        for (String string : storageid)
        {
            storageService.deleteForStorage(string);
        }
        
        List<StorageShowBean> storageShowList = storageService.queryForStorageList(storageParameBean);
        request.setAttribute("storageList", storageShowList);
        return SUCCESS;
    }
    
    public String showForStorage()
    {
        super.clientCache();
        HttpServletRequest request = super.getRequest();
        
        storageid = request.getParameter("storageid");
        StorageShowBean storageShowBean = storageService.queryForStorage(storageid);
        request.setAttribute("storageBean", storageShowBean);
        return SUCCESS;
    }

    public ChipmodelService getChipmodelService()
    {
        return chipmodelService;
    }

    public void setChipmodelService(ChipmodelService chipmodelService)
    {
        this.chipmodelService = chipmodelService;
    }

    public MeasurementService getMeasurementService()
    {
        return measurementService;
    }

    public void setMeasurementService(MeasurementService measurementService)
    {
        this.measurementService = measurementService;
    }

    public StorageParameBean getStorageParameBean()
    {
        return storageParameBean;
    }

    public void setStorageParameBean(StorageParameBean storageParameBean)
    {
        this.storageParameBean = storageParameBean;
    }
    
}
